import request from "@/api/config";
import { AxiosPromise } from 'axios';
import {PORT} from "@/leadmall/api/config/servicePort";
import { ProjectUserVO, ProjectUserForm, ProjectUserQuery } from '@/leadmall/api/projectUser/types';

/**
 * 查询项目成员列表
 * @param query
 * @returns {*}
 */

export const listProjectUser = (query?: ProjectUserQuery): AxiosPromise<ProjectUserVO[]> => {
  return request({
    url: PORT +'/leadmall/projectUser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目成员详细
 * @param id
 */
export const getProjectUser = (id: string | number): AxiosPromise<ProjectUserVO> => {
  return request({
    url: PORT +'/leadmall/projectUser/' + id,
    method: 'get'
  });
};

/**
 * 新增项目成员
 * @param data
 */
export const addProjectUser = (data: ProjectUserForm) => {
  return request({
    url: PORT +'/leadmall/projectUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目成员
 * @param data
 */
export const updateProjectUser = (data: ProjectUserForm) => {
  return request({
    url: PORT +'/leadmall/projectUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目成员
 * @param id
 */
export const delProjectUser = (id: string | number | Array<string | number>) => {
  return request({
    url: PORT +'/leadmall/projectUser/' + id,
    method: 'delete'
  });
};
